﻿package com.wxsoft.business.sys.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.wxsoft.business.model.easyui.PageHelper;
import com.wxsoft.business.sys.dao.ISysDictDao;
import com.wxsoft.business.sys.pojo.SysDict;
import com.wxsoft.business.sys.service.ISysDictService;

@Service("sysDictService")
public class SysDictServiceImpl implements ISysDictService  {
	@Resource
	private ISysDictDao dao;
	
	
	public long findCount(SysDict sysDict) {
		return dao.findCount(sysDict);
	}
	
	public List<SysDict> findAll(PageHelper page,SysDict sysDict) {
        List<SysDict> r = dao.findAll(page,sysDict);
		return r;
	}
	@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
	public String add(SysDict sysDict) {
		if("".equals(sysDict.getPid())){
			sysDict.setPid("0");
		}
		
		this.dao.insert(sysDict);
		return "操作成功!";
	}
	
	public String modify(SysDict sysDict) {
		this.dao.modify(sysDict);
		return "操作成功!";
	}
	
	public String delete(SysDict sysDict) {
		this.dao.delete(sysDict);
		return "操作成功!";
	}
	/**
	 * 根据类型返回字段选项
	 */
	public List<SysDict> findByType(String pid){
		List<SysDict> r = dao.findByType(pid);
		return r ;
	}
	
}
